<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            width: 100px;
            height: 100px;
            background-color: aquamarine;
        }
    </style>
    <script>
        window.onload = function(){

            //获取box1
            var box1 = document.getElementById('box1');
            //获取bt1
            var bt1 = document.getElementById('bt1');
            //添加单击响应函数
            bt1.onclick = function(){
                //修改宽度
                box1.style.width = '300px';
                box1.style.height = '300px';
                box1.style.backgroundColor = 'lightblue';
            }
            var bt2 = document.getElementById('bt2');
            bt2.onclick = function(){
                //查看内联样式
                // alert(box1.style.width);
                // alert(box1.style.height);
                // alert(box1.style.backgroundColor);

                //查看当前样式
                var obj = getComputedStyle(box1,null);
                alert(obj.width);
                alert(obj.height);
                alert(obj.backgroundColor);
            }
        
        }
    </script>
</head>
<body>
    <div id="box1">
        <button id="bt1">点我改变样式</button>
        <button id="bt2">点击查看样式</button>
    </div>
</body>
</html>